<?php

session_start();

// this sets variables in the session 

include_once('connection.php');

$productID = $_POST['id'];
//..$sql = "DELETE FROM cart WHERE productId=$productID AND userId = ".$_SESSION['id'];
//..$result = mysql_query($sql);
$arrlength=count($_SESSION['cart']);

for($x=0;$x<$arrlength;$x++)
  {
  //echo $_SESSION['cart'][$x];
     $arr = explode("," ,$_SESSION['cart'][$x]);
	 //echo $arr[0] . 'dsf' . $arr[1];
	 if($arr[0] == $productID && $arr[1] == $_SESSION['id']){
		unset($_SESSION['cart'][$x]);
		$_SESSION['cart'] = array_values($_SESSION['cart']);

	 }
  }

$count = 0;
$userID = $_SESSION['id'];
//                echo $userID;
//                    $count = 0;
//..$sql = "SELECT * FROM `cart` WHERE active = 1 AND userId = " . $userID . "";
//..$result = mysql_query($sql);
//                    while($row=  mysql_fetch_array($result)){
//                        $count++;
//                    }
//..$count = mysql_num_rows($result);
//                echo $count;
echo '<img src="images/cart.png" width="25px"/>
    <p id="cartParagraph" content="' . (count($_SESSION['cart'])) . '">[' . (count($_SESSION['cart'])) . ']</p>';
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
